﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace ProjectSem3.Admin
{
    public partial class WebForm7 : System.Web.UI.Page
    {
        public Product pr = new Product();

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Request.QueryString["ID"] != null)
                {
                    try
                    {
                        pr = new dataDataContext().Products.Single(p => p.ProductID == Convert.ToInt32(Request.QueryString["ID"]));
                        if (pr.ImagesPros.Count > 0)
                            foreach (ImagesPro img in pr.ImagesPros)
                            {
                                divImgs.InnerHtml += " <img src='../images/Product/" + img.NameImg + "' alt='' width='45px' height='50px' /> &nbsp;&nbsp;&nbsp; ";
                            }
                        else
                            divImgs.InnerHtml = "No image";

                        var data = from a in new dataDataContext().StockDetails
                                   where a.ProductID == Convert.ToInt32(Request.QueryString["ID"].ToString().Trim())
                                   select new { date = a.DateIn, Import = a.Import == null ? 0 : a.Import, Export = a.Export == null ? 0 : a.Export };

                        ListView1.DataSource = data.ToList();
                        ListView1.DataBind();
                    }
                    catch (Exception)
                    {
                        Response.Redirect("Stock.aspx");
                    }
                }
                else
                {
                    Response.Redirect("Stock.aspx");
                }
            }

        }

      







    }
}